package ua.maxicash.util.criteria.handlers;

import org.hibernate.criterion.DetachedCriteria;

import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Restrictions;
import ua.maxicash.util.Filter;
import ua.maxicash.util.criteria.RestrictionsWrapper;

import java.util.List;

public class EmailCriteriaHandler extends  CriteriaHandler {

private Filter filter;

    public EmailCriteriaHandler(List<String> aliases) {
        super(aliases);
    }

    public EmailCriteriaHandler() {
    }

    @Override
	public void setUp(Filter filter) {
		this.filter = filter;
	}

	@Override
	public DetachedCriteria handle(DetachedCriteria criteria, Junction junction) {



            junction.add(RestrictionsWrapper.getCriterion(filter.getOp(),
					"email", filter.getData()));
	        return criteria;
	}

}
